package com.ldzy.tinyaccount;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import java.util.Timer;
import java.util.TimerTask;

public class SplashActivity extends AppCompatActivity {
    private int imageIndex=0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        ImageView imageView=findViewById(R.id.Image_View_pic);
        Button buttonLogin=findViewById(R.id.buttonLogin);
        int [] image={R.drawable.splash_background,R.drawable.splash_background,R.drawable.splash_background};

        Handler handler=new Handler(){
            @Override
            public void handleMessage(@NonNull Message msg) {
                super.handleMessage(msg);
                    if(imageIndex++==3)
                        imageIndex=0;
                        imageView.setImageResource(image[imageIndex]);

            }
        };
//        new  Thread(new Runnable() {
//            @Override
//            public void run() {
//                try {
//                    Thread.sleep(3000);
//                }catch (InterruptedException e){
//                    e.printStackTrace();
//                }
//            }
//        }).start();

        new Timer().schedule(new TimerTask() {
            @Override
            public void run() {
                handler.sendEmptyMessage(1);

            }
        }, 0, 1000);

        buttonLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent =new Intent(SplashActivity.this,LoginActivity.class);
                intent.putExtra("login","login");
                startActivity(intent);
                fileList();
//                Intent intent = new Intent();
//                intent.setAction(Intent.ACTION_VIEW);
//                intent.setData(Uri.parse("http://www.baidu.com"));
//                startActivity(intent);
            }
        });
    }
}